package com.lxh.lxhcrm.model.pojos;

import javax.persistence.*;
import java.util.Objects;

/**
 * 申请采购详细表
 */
@Entity
@Table(name = "app_detail", schema = "lxh_crm", catalog = "")
public class AppDetail {
    private int appDetailId;    //详细表id
    private Double appCount;    //产品数量
    private Double appPrice;    //产品单价
    private Double appTotal;    //产品总价

    private ProDetail proDetail;
    private AppCai appCai;

    @ManyToOne
    @JoinColumn(name = "pro_detail_id",referencedColumnName="pro_detail_id")
    public ProDetail getProDetail() {
        return proDetail;
    }

    public void setProDetail(ProDetail proDetail) {
        this.proDetail = proDetail;
    }

    @ManyToOne
    @JoinColumn(name = "app_cai_id")
    public AppCai getAppCai() {
        return appCai;
    }

    public void setAppCai(AppCai appCai) {
        this.appCai = appCai;
    }

    @Id
    @Column(name = "app_detail_id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public int getAppDetailId() {
        return appDetailId;
    }

    public void setAppDetailId(int appDetailId) {
        this.appDetailId = appDetailId;
    }

    @Basic
    @Column(name = "app_count", nullable = true, precision = 0)
    public Double getAppCount() {
        return appCount;
    }

    public void setAppCount(Double appCount) {
        this.appCount = appCount;
    }

    @Basic
    @Column(name = "app_price", nullable = true, precision = 0)
    public Double getAppPrice() {
        return appPrice;
    }

    public void setAppPrice(Double appPrice) {
        this.appPrice = appPrice;
    }

    @Basic
    @Column(name = "app_total", nullable = true, precision = 0)
    public Double getAppTotal() {
        return appTotal;
    }

    public void setAppTotal(Double appTotal) {
        this.appTotal = appTotal;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AppDetail appDetail = (AppDetail) o;
        return appDetailId == appDetail.appDetailId &&
                Objects.equals(appCount, appDetail.appCount) &&
                Objects.equals(appPrice, appDetail.appPrice) &&
                Objects.equals(appTotal, appDetail.appTotal) &&
                Objects.equals(proDetail, appDetail.proDetail) &&
                Objects.equals(appCai, appDetail.appCai);
    }

    @Override
    public int hashCode() {
        return Objects.hash(appDetailId, appCount, appPrice, appTotal, proDetail, appCai);
    }
}